#include<bits/stdc++.h>
using namespace std;
const int N = 305;
int n,a[N],b[N],ans;
string str;
int S[N],mn[N],curS[N];
bool check()
{
    mn[n+1] = n+1;
    for(int i = 1;i <= n;i++) S[i] = S[i-1] + b[i];
    for(int i = n;i > 0;i--) mn[i] = min(mn[i+1],S[i]);
    if(mn[1] >= 0 && S[n] == 0) return 1;
    for(int i = 1;i <= n;i++)
    {
        for(int j = i,cur = S[i-1];j <= n;j++)
        {
            cur -= b[j];
            if(cur < 0) break;
            if(cur - S[j] + mn[j+1] >= 0 && S[n] - S[j] + cur == 0) return 1;
        }
        if(S[i] < 0) return 0;
    }
    return 0;
}
void dfs(int x)
{
    if(x > n)
    {
        if(check()) ans++;
        return ;
    }
    b[x] = a[x];
    if(a[x] == 0)
    {
        b[x] = 1;
        dfs(x+1);
        b[x] = -1;
        dfs(x+1);
    }
    else dfs(x+1);
}
int main()
{
    freopen("bracket.in","r",stdin);
    freopen("bracket.out","w",stdout);
    ios::sync_with_stdio(false);cin.tie(0);
    cin>>n>>str;
    for(int i = 1;i <= n;i++)
    {
        if(str[i-1] == '(') a[i] = 1;
        else if(str[i-1] == ')')a[i] = -1;
        else a[i] = 0;
    }
    dfs(1);
    cout<<ans<<"\n";
    return 0;
}